<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>总括账明细</title>
    <meta name="decorator" content="default"/>
    <script src="${ctxStatic}/lodop/LodopFuncs.js" type="text/javascript"></script>
    <script>
        $(function(){
            $("[name='bkType']").hide();

            $("[name='rangeType']").click(function(){
                var rangeType = $(this).val();
                if (rangeType == 2 || rangeType == 3) {
                    $("[name='begin']").show();

                    $("[name='beginDate']").hide();
                    $("#gang").hide();
                    $("[name='endDate']").hide();

                } else {
                    $("[name='begin']").hide();

                    $("[name='beginDate']").show();
                    $("#gang").show();
                    $("[name='endDate']").show();
                }
            });

            <c:if test="${not empty ledgerSearch.rangeType and ledgerSearch.rangeType !=1}">
                $("[name='begin']").show();

                $("[name='beginDate']").hide();
                $("#gang").hide();
                $("[name='endDate']").hide();
            </c:if>
            <c:if test="${not empty ledgerSearch.rangeType and ledgerSearch.rangeType ==1}">
                $("[name='begin']").hide();

                $("[name='beginDate']").show();
                $("#gang").show();
                $("[name='endDate']").show();
            </c:if>
        });
        function exportExcel() {
            parent.$.jBox.confirm("确认要导出总括明细帐吗？", "系统提示", function (v, h, f) {
                if (v == "ok") {
                    $("#searchForm").attr("action", "${ctx}/report/exportGeneralLedgerDetail").submit();
                }
            });
        }
        function searchLedger() {
            $("#searchForm").attr("action", "${ctx}/report/generalLedgerDetail").submit();
        }
    </script>
    <style>
        .ul-form li{  width: 100%;  }  .form-search .ul-form li label{  width: initial;  }
        .ul-form-1 label span{  width: 130px;text-align: left;  }  .form-search .ul-form li label{  text-align: inherit;  }
        .form-search label{margin-left: 0;}
    </style>
</head>
<body>
<form:form id="searchForm" modelAttribute="ledgerSearch" action="${ctx}/report/generalLedgerDetail" method="post" class="breadcrumb form-search">
    <ul class="ul-form">
        <li class="ul-form-1">
            <%-- 账目类型 --%>
            <label class="checkbox inline" style="width: 450px;">
                <form:radiobutton path="searchType" label="图书登记总帐" value="1"/>
                <form:radiobutton path="searchType" label="图书收入总括登记帐" value="2"/>
                <form:radiobutton path="searchType" label="图书分类登记帐" value="3"/>
            </label>
            <form:select path="bkType" style="width: 60px;" >
                <form:option value=""/>
                <form:options items="${bkTypes}" itemValue="typName" itemLabel="typName"/>
            </form:select>
        </li>
        <li>
            <form:select path="rangeType" style="width: 110px;" >
                <form:option value="0" label="请选择"/>
                <form:option value="1" label="验收时间"/>
                <form:option value="2" label="验收批次"/>
                <form:option value="3" label="发票号"/>
            </form:select>

            <form:input path="begin" type="text" maxlength="20" class="input-small"/>

            <input id="beginDate" name="beginDate"  type="text" readonly="readonly" maxlength="20" class="input-medium Wdate" style="width:120px;display: none;"
                   value="<fmt:formatDate value="${ledgerSearch.beginDate}" pattern="yyyy-MM-dd"/>"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:'#F{$dp.$D(\'endDate\')}'});" />
            <label id="gang" style="display: none;">--</label>
            <input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate" style="width:120px;display: none;"
                   value="<fmt:formatDate value="${ledgerSearch.endDate}" pattern="yyyy-MM-dd"/>"
                   onclick="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:'#F{$dp.$D(\'beginDate\')}'});"/>
        </li>
        <li>
            馆藏地点
            <form:select path="store" style="width: 110px;">
                <form:option value="" label=""/>
                <c:forEach items="${bkPlaces}" var="place">
                    <form:option value="${place.id}" label="${place.gcdName}"/>
                </c:forEach>
            </form:select>
           <%-- 出馆
            <select name="rangeType" style="width: 110px;">
                <option></option>
                <option>验收时间</option>
                <option>验收批次</option>
                <option>发票号</option>
            </select>
            来源
            <select name="rangeType" style="width: 110px;">
                <option></option>
                <option>验收时间</option>
                <option>验收批次</option>
                <option>发票号</option>
            </select>--%>
            <a id="btnSubmit" href="javascript:void(0)" onclick="searchLedger()" class="btn">查询</a>&nbsp;&nbsp;
            <a id="btnExport" href="javascript:void(0)" onclick="exportExcel()" class="btn">导出Excel</a>
        </li>
    </ul>
</form:form>
<div id="ledgerContent">
    <style type="text/css" scoped>
        .table-bordered th, .table-bordered td { border-left: 1px solid #ddd; } .table th, .table td { line-height: 20px; text-align: left; border-top: 1px solid #ddd; } .table-bordered { border: 1px solid #ddd; border-collapse: separate; border-left: 0; border-radius: 4px; }
    </style>
    <div style="width: 1400px;">
        <div style="width: 100%;text-align: center">
            <h3>总括明细帐</h3>
        </div>
        <table id="contentTable" style="width: 100%;" class="table table-striped table-bordered table-condensed">
            <tr>
                <th style="width:100px;">验收日期</th>
                <th style="width:120px;">条码号</th>
                <th style="width:120px;">分类/排架号</th>
                <th style="width:220px;">书名</th>
                <th style="width:60px;">责任者</th>
                <th style="width:160px;">出版社</th>
                <th style="width:100px;">出版年月</th>
                <th style="width:60px;">来源</th>
                <th style="width:60px;">页数</th>
                <th style="width:60px;">定价</th>
                <th style="width:120px;">备注</th>
                <th style="width:100px;">出馆时间</th>
                <th style="width:60px;">操作者</th>
            </tr>
            <c:forEach items="${generalledger}" var="r" varStatus="status">
                <tr>
                    <td><fmt:formatDate value="${r.createDate}" pattern="yyyy-MM-dd"/></td>
                    <td style="text-align:right;">${r.banid}</td>
                    <td style="text-align:right;">${r.classcode}</td>
                    <td style="text-align:right;">${r.bookname}</td>
                    <td style="text-align:right;">${r.author}</td>
                    <td style="text-align:right;">${r.publisher}</td>
                    <td style="text-align:right;">${r.pubdate}</td>
                    <td style="text-align:right;">
                        <c:if test="${'C' eq r.source}">
                            购买
                        </c:if>
                    </td>
                    <td style="text-align:right;">${r.pages}</td>
                    <td style="text-align:right;">${r.price}</td>
                    <td style="text-align:right;">${r.remarks}</td>
                    <td style="text-align:right;"><fmt:formatDate value="${r.storeDate}" pattern="yyyy-MM-dd"/></td>
                    <td style="text-align:right;">${r.createBy}</td>
                </tr>
            </c:forEach>
            <tr>
                <td colspan="3">册数:${count}</td>
                <td colspan="10">总金额:${total}</td>
            </tr>
        </table>
    </div>
</div>
<object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <param name="Border" value="1">
    <param name="Color" value="white">
    <embed id="LODOP_EM" TYPE="application/x-print-lodop" width=0 height=0 border=0 Color="white"
           PLUGINSPAGE="install_lodop.exe">
</object>
<script type="text/javascript">
    /**
     *  打印预览
     */
    //声明为全局变量
    var LODOP;
    function print() {
        LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM'));
        LODOP.PRINT_INIT("打印");
        LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");

        LODOP.ADD_PRINT_HTM(20, 20, 600, 800, $("#ledgerContent").html());
        LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT","Full-Width");//按整页缩放

        LODOP.PRINT_DESIGN();
        LODOP.SHOW_CHART();
    }
</script>
</body>
</html>